package com.zy.edu.controller;


import com.zy.edu.bean.CourseChapterExercises;
import com.zy.edu.bean.InputParam;
import com.zy.edu.service.CourseChapterExercisesService;
import com.zy.edu.service.CourseChapterExercisesStuService;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-07-28
 */
@RestController
@RequestMapping("/exercises")
public class CourseChapterExercisesController {
    @Resource
    CourseChapterExercisesService courseChapterExercisesService;

    /**
     * @Author: HuangHaiShui
     * @Description: 数据的新增与修改
     * @Date: 9:17 2021/7/28
     * @param courseChapterExercises:
     * @return: Map
     **/
    @RequestMapping("/edit")
    public Map edit(CourseChapterExercises courseChapterExercises, InputParam inputParam) throws Exception {
        return courseChapterExercisesService.saveOrUpdate(courseChapterExercises,inputParam);
    }

    //批量编辑习题
//    @RequestMapping("/batchSave")
//    public Map batchSave( InputParam inputParam) throws Exception {
//        return courseChapterExercisesService.batchSave(inputParam);
//    }

    //获取某个课程的所有习题
    @RequestMapping("/list")
    public Map list(CourseChapterExercises courseChapterExercises, InputParam inputParam){

        return courseChapterExercisesService.list(courseChapterExercises, inputParam);
    }


    /**
     * @Author: HuangHaiShui
     * @Description: 删除数据
     * @Date: 9:18 2021/7/28
     * @param courseChapterExercises:  传入id 字段
     * @return: Map
     **/
    @RequestMapping("/dele")
    public Map dele( CourseChapterExercises courseChapterExercises){
        return courseChapterExercisesService.dele(courseChapterExercises);
    }
    @RequestMapping("/getById")
    public Map getById(CourseChapterExercises courseChapterExercises, InputParam inputParam){

        return courseChapterExercisesService.getById(courseChapterExercises, inputParam);
    }


    /**
     * @Author: HuangHaiShui
     * @Description:学生提交习题
     * @Date: 15:34 2021/7/28
     * @param inputParam:
     *                  userId  学生id
     *                  chapterId  课时id
     *                  exerciseStr  答案字符串，
     *                      题与题之间逗号隔开
     *                      题目id与答案直接 双横线 隔开
     * @return: Map
     **/
    @RequestMapping("/submit")
    public Map stuSubmit( InputParam inputParam){

        return courseChapterExercisesService.stuSubmit( inputParam);
    }


    /**
     * @Author: HuangHaiShui 
     * @Description:查询某个学生某课时的习题情况
     * @Date: 16:22 2021/7/28
     * @param inputParam:
     *                  userId  学生id
     *                  chapterId  课时id
     * @return: Map
     **/
    @RequestMapping("/getByStuId")
    public Map getByStuId(InputParam inputParam){
        return courseChapterExercisesService.getByStuId(inputParam);
    }

}

